home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '88 / Other stuff / CLIP stuff / CLIP sources / mkmxl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-05-07  |  3.3 KB  |  101 lines  |  [TEXT/FstE]

  1. /*  Copyright (c)   Mar, 1986   UMMC.  All rights reserved
  2.  
  3. Filename:       mkmxl.c
  4.  
  5. Abstract:       This module contains the code to construct the matrices used to transform between
  6.                 The LAT image coordinates and the patient/table coordinates
  7.  
  8. Environment:    UM/CLIP
  9.  
  10. Revision History:
  11.    Rev #       Date    Auth     Reason
  12.    -----    ---------  -----    ----------------------------------
  13.     0.0     17-mar-86   js      original implementation
  14.     0.1     28-apr-86   js      converted to double precision
  15.     
  16. -----------------------------------------------------------------------------------------
  17. NAME:
  18.         mkmxl - make coordinate transform matrices (LAT)
  19.  
  20. SYNOPSIS:
  21.  
  22.         ERRCODE mkmxl (alpha, beta, l2p, p2l)
  23.         
  24.         INT     alpha;      angle alpha for the LAT C-arm
  25.         INT     beta;       angle beta for the LAT C-arm
  26.         DOUBLE  l2p[9];     array for 'LAT to patient' transform matrix
  27.         DOUBLE  p2l[9];     array for 'patient to LAT' transform matrix
  28.  
  29. MODIFIED ARGUMENTS:
  30.  
  31.         l2p and p2l will contain the transform matrices corresponding to angles alpha and beta
  32.  
  33. FUNCTION:
  34.  
  35.         Matrix methods are used in order to implement transformations between the coordinate
  36.         systems subtended by the LAT image plane and the patient.  It is the function of this
  37.         routine to construct the  required matrices based on the angulation of the C-arm.  The
  38.         form of the matrices is the following (a = alpha & b = beta):
  39.         
  40.                 p2l:
  41.                 
  42.                     -cos a sin b    -cos b      sin a sin b
  43.                     -sin a          0           -cos a
  44.                     -cos a cos b    sin b       sin a cos b
  45.                     
  46.                 l2p:
  47.                 
  48.                     -cos a sin b    -sin a      -cos a cos b
  49.                     -cos b          0           sin b
  50.                     sin a sin b     -cos a      sin a cos b
  51.  
  52. PROGRAMMING NOTES:
  53.  
  54.     The elements of the matrices will be stored as sequential rows in the array.
  55.  
  56. EXAMPLES:
  57.  
  58. =========================================================================*/
  59.  
  60. #include    "clipinclude.h"
  61.  
  62.     ERRCODE mkmxl (alpha, beta, l2p, p2l)
  63.         
  64.     INT     alpha;      /* angle alpha for the LAT C-arm */
  65.     INT     beta;       /* angle beta for the LAT C-arm */
  66.     DOUBLE  l2p[9];     /* array for 'LAT to patient' transform matrix */
  67.     DOUBLE  p2l[9];     /* array for 'patient to LAT' transform matrix */
  68.  
  69.     {
  70.     
  71.     DOUBLE      sina, cosa;         /* sine and cosine of alpha */
  72.     DOUBLE      sinb, cosb;         /* sine and cosine of beta */
  73.     ERRCODE     erret = OK;         /* error code */
  74.     
  75.     DOUBLE      sin ();             /* sine function */
  76.     DOUBLE      cos ();             /* cosine function */
  77.     
  78. /* get copies of sine's and cosine's */
  79.  
  80.     sina = sin((DOUBLE)alpha * Pi / 180);
  81.     cosa = cos((DOUBLE)alpha * Pi / 180);
  82.     sinb = sin((DOUBLE)beta * Pi / 180);
  83.     cosb = cos((DOUBLE)beta * Pi / 180);
  84.     
  85. /* construct matrices */
  86.  
  87.     p2l[0] = l2p[0] = -cosa * sinb;
  88.     p2l[1] = l2p[3] = -cosb;
  89.     p2l[2] = l2p[6] = sina * sinb;
  90.     p2l[3] = l2p[1] = -sina;
  91.     p2l[4] = l2p[4] = 0;
  92.     p2l[5] = l2p[5] = -cosa;
  93.     p2l[6] = l2p[2] = -cosa * cosb;
  94.     p2l[7] = l2p[5] = sinb;
  95.     p2l[8] = l2p[8] = sina * cosb;
  96.     
  97. /* all done */
  98.  
  99.     return (erret);
  100.     
  101.     }